package com.huishen.edrivenew.bean;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.huishen.edrivenew.base.BaseBean;

/**
 * 教练列表
 * @author wu
 *
 */

public class CoachListBean extends BaseBean {
    
    public int begin;
    public int page;
    public int size;
    
    public int total;
    
    // 客户端用 已加载页数
    public int currPage = 1;
    //已加载数目
    public int currSize = 0;
    public int currTotal = 0;
    
    
    public boolean hasDone = false;
    
    
    public List<CoachBean> rows;
    
    
    public void addDate(CoachListBean newList) {
        if(this.rows == null) {
            this.rows = new ArrayList<CoachBean>();
        }
        
        if(newList.page == 1) {
            this.rows.clear();
            currSize = 0;
            hasDone = false;
        }
        this.rows.addAll(newList.rows);
        currSize += newList.size;

        currPage = newList.page;
        begin = newList.begin;
        currTotal = newList.total;
        
        if(currSize >= currTotal) {
            hasDone = true;
        }
    }
    
    
    
    public static BaseBean parseJson(JSONObject jsonObj) {
        Gson gson = new Gson();
        
        CoachListBean bean = gson.fromJson(jsonObj.toString(), CoachListBean.class);
        
        return bean;
    }
    
    
    
    
    
}
